#!/bin/bash

function update() {
    FILENAME=$1

    TMP=${FILENAME:0-6:6}
    if [[ $TMP == 'tar.gz' ]]
    then
        TMP=${FILENAME:0:0-7}
        NAME=${TMP%-*}
        VER=${TMP##*-}
    else
        NAME=$1
        VER=`cat ./img/$NAME/ver`
    fi

    echo -e "$VER\t$NAME"
}

#========================================

FILE_NEW=./new
ls img -1 > $FILE_NEW

while read v
do
    update $v
done < $FILE_NEW

rm -rf $FILE_NEW
